<template>
  <Form ref="formRef" :items="items" split-col="1" width="500px" style="margin-top: 20px;padding-right: 100px;"
        label-width="80" :show-reset="showReset" :rules="rules" @validateSuccess="validateSuccess">

  </Form>
</template>

<script setup>

import Form from "@/components/plugs/form/Form.vue";
import {FormItemType} from "@/components/plugs/form/DialogFormInterface.js";
import {AXIOS_NAME} from "@/constant/constant.js"
import {inject, ref, toRaw} from "vue";
import {ElMessage} from "element-plus";

const $axios = inject(AXIOS_NAME);
const formRef = ref(null);
const showReset = false;

let items = [];
items.push({type: FormItemType.INPUT_HIDDEN,label: 'id',name: 'id'});
items.push({type: FormItemType.INPUT_TEXT,label: '环境地址',name: 'dockerEnvFilePath'});

const rules = {
  dockerEnvFilePath: [
    { required: true, message: '请填写环境地址', trigger: 'blur' }
  ],
};

const validateSuccess = (data) =>{
  $axios.post("/deploy/updateDockerEnvFilePath",data).then(response =>{
    const data = response.data;
    if(data.code == 1){
      ElMessage.info(data.msg);
      return;
    }
    ElMessage.error(data.msg);
  });
}

const setData = (data) =>{
  formRef.value.setData(toRaw(data));
}

defineExpose({setData});

</script>

<style scoped>

</style>